<template>
  <div id="app">
    <h1>登录验证</h1>
    <form @submit.prevent="handleSubmit">
      <div>
        <label for="username">用户名：</label>
        <input type="text" id="username" v-model="username" />
      </div>
      <div>
        <label for="password">密码：</label>
        <input type="password" id="password" v-model="password" />
      </div>
      <button type="submit">登录</button>
    </form>
    <p v-if="isLoginSuccessful">登录成功！</p>
  </div>
</template>

<script>
import { ref } from "vue";

export default {
  setup() {
    const username = ref("");
    const password = ref("");
    const isLoginSuccessful = ref(false);

    const handleSubmit = () => {
      isLoginSuccessful.value = username.value === "admin" && password.value === "123456";
    };

    return {
      username,
      password,
      isLoginSuccessful,
      handleSubmit,
    };
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
